package com.lili.setting.controller;

import com.lili.common.result.Result;
import com.lili.model.setting.Menu;
import com.lili.setting.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/setting/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    /**
     * 添加一级二级菜单列表 权限符号
     *
     * @param menu
     * @return
     */
    @PostMapping("/save")
    public Result saveMenu(@RequestBody Menu menu) {
        menuService.saveMenu(menu);
        return Result.ok();
    }

    /**
     * 根据id 删除对应权限 可以多传根据 ,  分割
     * @param menuId
     * @return
     */
    @DeleteMapping("/delete/{menuId}")
    public Result deleteMenu(@PathVariable String menuId){

        String[] ids = menuId.split(",");
        menuService.deleteMenu(ids);

        return Result.ok();
    }


}
